const Router = require('koa-router')

const {
	verifyAuth,
	verifyPermission,
} = require('../middlewares/auth.middleware')

const { 
  create, 
  reply, 
  update,
  remove,
  list
} = require('../controllers/comment.controller')

const commentRouter = new Router({ prefix: '/comment' })

// 发表评论
commentRouter.post('/', verifyAuth, create)
// 对发表的评论进行评论
commentRouter.post('/:commentId/reply', verifyAuth, reply)

// 更新评论
commentRouter.patch('/:commentId', verifyAuth, verifyPermission, update)
// 删除评论
commentRouter.delete('/:commentId', verifyAuth, verifyPermission, remove)

// 获取某条动态的评论列表
commentRouter.get('/', list)

module.exports = commentRouter
